// Package sys
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2025 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.16.10
package sys

import (
	"context"
	"hotgo/api/admin/lunbo"
	"hotgo/internal/model/input/sysin"
	"hotgo/internal/service"
)

var (
	Lunbo = cLunbo{}
)

type cLunbo struct{}

// List 查看轮播管理列表
func (c *cLunbo) List(ctx context.Context, req *lunbo.ListReq) (res *lunbo.ListRes, err error) {
	list, totalCount, err := service.SysLunbo().List(ctx, &req.LunboListInp)
	if err != nil {
		return
	}

	if list == nil {
		list = []*sysin.LunboListModel{}
	}

	res = new(lunbo.ListRes)
	res.List = list
	res.PageRes.Pack(req, totalCount)
	return
}

// Export 导出轮播管理列表
func (c *cLunbo) Export(ctx context.Context, req *lunbo.ExportReq) (res *lunbo.ExportRes, err error) {
	err = service.SysLunbo().Export(ctx, &req.LunboListInp)
	return
}

// Edit 更新轮播管理
func (c *cLunbo) Edit(ctx context.Context, req *lunbo.EditReq) (res *lunbo.EditRes, err error) {
	err = service.SysLunbo().Edit(ctx, &req.LunboEditInp)
	return
}

// MaxSort 获取轮播管理最大排序
func (c *cLunbo) MaxSort(ctx context.Context, req *lunbo.MaxSortReq) (res *lunbo.MaxSortRes, err error) {
	data, err := service.SysLunbo().MaxSort(ctx, &req.LunboMaxSortInp)
	if err != nil {
		return
	}

	res = new(lunbo.MaxSortRes)
	res.LunboMaxSortModel = data
	return
}

// View 获取指定轮播管理信息
func (c *cLunbo) View(ctx context.Context, req *lunbo.ViewReq) (res *lunbo.ViewRes, err error) {
	data, err := service.SysLunbo().View(ctx, &req.LunboViewInp)
	if err != nil {
		return
	}

	res = new(lunbo.ViewRes)
	res.LunboViewModel = data
	return
}

// Delete 删除轮播管理
func (c *cLunbo) Delete(ctx context.Context, req *lunbo.DeleteReq) (res *lunbo.DeleteRes, err error) {
	err = service.SysLunbo().Delete(ctx, &req.LunboDeleteInp)
	return
}